import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
import { renderWithQiankun, qiankunWindow } from 'vite-plugin-qiankun/dist/helper';

function render(props = {}) {
  const { container, router: parentRouter, setGlobalState } = props;
  const app = createApp(App);
  app.use(createPinia());
  app.use(router);
  app.provide("setGlobalState", setGlobalState);
  app.provide("parentRouter", parentRouter);
  container ? app.mount(container) : app.mount("#app");
}

renderWithQiankun({
  mount(props) {
    render(props);
  },
  bootstrap() {
  },
  unmount(props) {
  },
});

if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
  render({});
}
